import gulp from 'gulp';
import gulpif from 'gulp-if';
import liveserver from 'gulp-live-server';
import nodemon from 'gulp-nodemon';
import args from './util/args';
import livereload from 'gulp-livereload';
gulp.task('serve',(cb)=>{
  if(!args.watch) return cb();
      var server = liveserver.new(['--harmony', 'app.js']);
      //this will achieve `node --harmony myapp.js` 
      //you can access cwd args in `myapp.js` via `process.argv` 
      server.start();
   
      //use gulp.watch to trigger server actions(notify, start or stop) 
      gulp.watch(['app/views/**/*.jade', 'static/js/*.js'], function (file) {
        console.log(file);
        server.notify.apply(server, [file]);
        console.log(666);
      });
      gulp.watch(['app/**/*.js'], function() {
        server.start.bind(server)()
      });
})